<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .father {
        position: relative;
        width: 300px;
        height: 300px;
        background-color: pink;
        margin: 100px auto;
      }
      .son {
        width: 200px;
        height: 200px;
        background-color: skyblue;
        text-align: center;
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        margin: auto;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="son">son盒子</div>
    </div>
    <script>
      // dom 事件流  三个阶段

      //4. 冒泡阶段 如果addEventListener 第三个参数是false 或者 省略 那么则处于冒泡切断
      var father = document.querySelector('.father');
      father.addEventListener('click', function () {
        //函数外不写 默认就是冒泡
        console.log('father');
      });
      var son = document.querySelector('.son');
      son.addEventListener('click', function () {
        //默认就是冒泡
        console.log('son');
      });
      document.body.addEventListener('click', function () {
        console.log('body');
      });
    </script>
  </body>
</html>
